<!doctype html>
<html>
	<head>
	</head>
	<body>
		<script src="../ocrad.js"></script>
		<script>
			function OCRImage(image){
				var canvas = document.createElement('canvas')
				canvas.width  = image.naturalWidth;
				canvas.height = image.naturalHeight;
				canvas.getContext('2d').drawImage(image, 0, 0)
				return OCRAD(canvas)
			}
			
			function OCRPath(url, callback){
				var image = new Image()
				image.src = url;
				image.onload = function(){ callback(OCRImage(image)) }
			}

			function OCRFile(file, callback){
				var reader = new FileReader();
				reader.onload = function(){ OCRPath(reader.result, callback); }
				reader.readAsDataURL(file)
			}
		</script>
		<input type="file" onchange="OCRFile(this.files[0], function(text){alert(text)})">
	</body>	
</html>
